import _extends from "@babel/runtime/helpers/esm/extends";
import {createNamespace} from '../utils';

var _createNamespace = createNamespace('swipe-item'),
    createComponent = _createNamespace[0],
    bem = _createNamespace[1];

export default createComponent({
    data: function data() {
        return {
            offset: 0
        };
    },
    beforeCreate: function beforeCreate() {
        this.$parent.swipes.push(this);
    },
    destroyed: function destroyed() {
        this.$parent.swipes.splice(this.$parent.swipes.indexOf(this), 1);
    },
    render: function render() {
        var h = arguments[0];
        var _this$$parent = this.$parent,
            vertical = _this$$parent.vertical,
            computedWidth = _this$$parent.computedWidth,
            computedHeight = _this$$parent.computedHeight;
        var style = {
            width: computedWidth + 'px',
            height: vertical ? computedHeight + 'px' : '100%',
            transform: "translate" + (vertical ? 'Y' : 'X') + "(" + this.offset + "px)"
        };
        return h("div", {
            "class": bem(),
            "style": style,
            "on": _extends({}, this.$listeners)
        }, [this.slots()]);
    }
});